import java.util.Random;
import java.util.Scanner;


public class Simple {

	private String[] categories = {"1. Structure","2. Object","3. Logic","4. Class"};
	private Object[][] questions = {{"this",0},{"new",1},{"if",2},{"extends",3}};
	private int points = 0;

	public static void main(String[] args) {
		Simple test = new Simple();
	}
	
	public Simple(){
		run();
	}
	

	public void run(){
		System.out.println("It's quiz times. Select the correct keyword or forever die:\n===========================================================\n");
		while(true){
			int answer = ask();
			selection();
			Scanner input = new Scanner(System.in);
			if(input.nextInt()-1 == answer){
				points++;
				System.out.println("Congratulation, you have " + points + " correct answers. Lets try again!\n\n");
			} else {
				System.out.println("You lost - you had "+points + " correct answers.");
				break;
			}
		}
	}
	
	public void selection(){
		for(String s : categories){
			System.out.println(s);
		}
		System.out.print("Please select: ");
	}
	
	public int ask(){
		Random rnd = new Random();
		int pick = rnd.nextInt(questions.length);
		System.out.println("What type of keyword is \""+questions[pick][0]+"\"?");
		return pick;
	}

}
